package com.yixun.qfbao.apidto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.yixun.qfbao.model.Department;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author zilong.liu
 * @date 2021-2-23
 *
 * desc:
 *     
 */
@Data
public class DeptTreeResDto implements Serializable {

	private static final long serialVersionUID = -2375348367543417171L;
	
	@ApiModelProperty("id")
	private Long value;
	
	@ApiModelProperty("部门名称")
	private String label;
	
	@ApiModelProperty("子集部门")
	private List<DeptTreeResDto> children;
	
	@ApiModelProperty("父节点")
	private Long parentId;
	
	@ApiModelProperty("层级")
	private int layer;
	
	/**
	 * 	添加子部门
	 */
	public void addChildren(DeptTreeResDto deptTreeResDto) {
		if(deptTreeResDto.getParentId().longValue() == this.value.longValue()) {
			if(this.children == null) {
				this.children = new ArrayList<>();
			}
			this.children.add(deptTreeResDto);
		}
	}
}
